// Created from GroupGenerationTemplate
// For Decisions HL7 Engine
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using DecisionsFramework.Design.Properties;
using Decisions.HL7.DataTypes;
using ST = System.String;
using SI = System.String;
using IS = System.String;
using ID = System.String;
using SNM = System.String;

namespace Decisions.HL7.Message
{
    [DataContract]
	public class INSURANCE_ADT_A01 : AbstractGroup
    {
        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("56 IN1",56)]
  	    [HL7Field(HL7Version.v23, 56, HL7Repeat.False, HL7Required.True,"IN1")]
	    public IN1 IN1 {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("58 IN2",58)]
  	    [HL7Field(HL7Version.v23, 58, HL7Repeat.False, HL7Required.False,"IN2")]
	    public IN2 IN2 {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("61 IN3",61)]
  	    [HL7Field(HL7Version.v23, 61, HL7Repeat.False, HL7Required.False,"IN3")]
	    public IN3 IN3 {get;set;}



		#region Parser Helpers and Conrete Impls

        internal override void ConsumeTextSegmentsForGroup(Stack<string> availableData, HL7ParserOptions options) {

			IN1 = PopSegmentParseAndCheckRequired<IN1>(availableData, options, "IN1");
			IN2 = PopSegmentParseAndCheckRequired<IN2>(availableData, options, "IN2");
			IN3 = PopSegmentParseAndCheckRequired<IN3>(availableData, options, "IN3");
        }

		internal override bool CanConsume(string availableData, HL7ParserOptions options)
        {
			bool isIN1 = availableData.StartsWith("IN1", StringComparison.OrdinalIgnoreCase);
			if (IsRequired("IN1", options.Version) || isIN1) {
				return isIN1;
			}
			bool isIN2 = availableData.StartsWith("IN2", StringComparison.OrdinalIgnoreCase);
			if (IsRequired("IN2", options.Version) || isIN2) {
				return isIN2;
			}
			bool isIN3 = availableData.StartsWith("IN3", StringComparison.OrdinalIgnoreCase);
			if (IsRequired("IN3", options.Version) || isIN3) {
				return isIN3;
			}
			return false;
        }

        private static Dictionary<string, bool> SEGMENT_VERSION_REQUIRED_MAP = new Dictionary<string, bool>();

		protected override Dictionary<string, bool> MAP_OF_SEGMENT_TO_REQUIRED
        {
            get
			{
				return SEGMENT_VERSION_REQUIRED_MAP;
			}
        }

		public override string HL7ENTITY_TYPE_NAME
        {
            get {
				return "INSURANCE";
			}
        }

        static INSURANCE_ADT_A01() {

             SetupStaticPropertyMap(SEGMENT_VERSION_REQUIRED_MAP, typeof(INSURANCE_ADT_A01));

        }

		#endregion

		public override string GetER7(HL7ParserOptions options)
		{
			List<string> segmentData = new List<string>();
		 if (IN1 != null) {
			string segmentValue = IN1.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
		 if (IN2 != null) {
			string segmentValue = IN2.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
		 if (IN3 != null) {
			string segmentValue = IN3.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
           return string.Join(HL7ParserConstants.SEGMENT_SEPARATOR, segmentData.ToArray());
        
        }
    }
}

